using UnityEngine;
using UnityEngine.UI;
using System;

namespace UITools
{
	[AddComponentMenu("UITools/TriggerObject")]
	public class TriggerObject : MonoBehaviour
	{
		public GameObject TargetObject;

		void Start()
		{
			Button btn = gameObject.GetComponent<Button> ();
			if (btn != null) {
				btn.onClick.AddListener (Switch);
			}
		}

		public void Switch()
		{
			if (TargetObject == null)
				return;

			TargetObject.SetActive (!TargetObject.activeInHierarchy);
		}
	}
}

